<template>
  <div class="app-container">
    <h2>人才招聘</h2>

    <search-box
      :fields="searchFeilds"
      @search="handleSearch"
      @add="handleAdd"
    />

    <SearchResult
      uid="careers"
      ref="searchResult"
      @edit="handleEdit"
      @detail="handleDetail"
    >
      <!-- <el-table-column type="expand">
        <template slot-scope="{ row }">
          <el-form label-position="top" class="demo-table-expand">
            <el-form-item label="岗位要求">
              <span>{{ row.positionRequire }}</span>
            </el-form-item>
            <el-form-item label="岗位职责">
              <span>{{ row.positionDuties }}</span>
            </el-form-item>
            <el-form-item label="在线申请">
              <span>{{ row.onlineApply }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column> -->
      <el-table-column label="职位" prop="position" />
      <el-table-column label="薪资" prop="salary" />
      <el-table-column label="经验要求" prop="experienceRequire" />
      <el-table-column label="学历要求" prop="educationRequire" />
      <el-table-column label="职位性质" prop="positionNature">
        <template slot-scope="{row}">
          {{ row.positionNature == 1 ? '全职' : '兼职' }}
        </template>
      </el-table-column>
      <el-table-column label="工作地点" prop="workSite" />

      <el-table-column label="是否启用" align="center">
        <template slot-scope="{row}">
          <span>{{ row.isEnable === 1 ? '是' : '否' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否删除" align="center">
        <template slot-scope="{row}">
          <span>{{ row.isEnable === 1 ? '是' : '否' }}</span>
        </template>
      </el-table-column>
    </SearchResult>
  </div>
</template>
<script>
import Tinymce from '@/components/Tinymce';
import waves from '@/directive/waves';
import SearchBox from '@/components/SearchBox';
import SearchResult from '@/components/SearchResult';
import * as config from '@/utils/config';

export default {
  name: 'careers',
  components: { Tinymce, SearchBox, SearchResult },
  directives: { waves },
  data() {
    return {
      searchFeilds: [
        { name: 'Position', label: '职位', type: 'list', options: config.positionOptions },
        { name: 'Salary', label: '薪资', type: 'list', options: config.salaryOptions },
        { name: 'ExperienceRequire', label: '经验要求', type: 'list', options: config.experienceRequireOptions },
        { name: 'EducationRequire', label: '学历要求', type: 'list', options: config.educationRequireOptions },
        { name: 'WorkSite', label: '工作地点', type: 'list', options: config.workSiteOptions },
        { name: 'PositionRequire', label: '岗位要求', type: 'text' },
        { name: 'PositionDuties', label: '岗位职责', type: 'text' },
        { name: 'IsEnable', label: '是否启用', type: 'list', options: config.isEnableOptions },
        { name: 'IsDelete', label: '是否删除', type: 'list', options: config.isEnableOptions }
      ]
    };
  },
  methods: {
    // 搜索
    handleSearch(data) {
      if (data === void 0) data = {};

      this.$refs['searchResult'].getData(data);
    },

    // 添加
    handleAdd() {
      this.$store.dispatch({ type: 'recruitment/setRecruitmentMap', payload: {} });
      this.$router.push(`/recruitment/message`);
    },

    // 编辑
    handleEdit(row) {
      this.$store.dispatch({ type: 'recruitment/setRecruitmentMap', payload: row });
      this.$router.push(`/recruitment/message`);
    },

    // 编辑
    handleDetail(row) {
      this.$store.dispatch({ type: 'recruitment/setRecruitmentMap', payload: row });
      this.$router.push(`/recruitment/detail`);
    }
  }
}
</script>
